package irri.soils.ssnm;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

@SuppressWarnings("rawtypes")
public class CircularArrayAdapter extends ArrayAdapter {
	public static final int HALF_MAX_VALUE = Integer.MAX_VALUE/2;
    public final int MIDDLE;
    public Object[] objects;
    @SuppressWarnings("unused")
	private int[] colors = new int[] { 0x30FFFFBB, 0x30AAAAAA };

    @SuppressWarnings("unchecked")
	public CircularArrayAdapter(Context context, int textViewResourceId, Object[] objects)
    {
        super(context, textViewResourceId, objects);
        this.objects = objects;
        MIDDLE = HALF_MAX_VALUE - HALF_MAX_VALUE % objects.length;
    }

    @Override
    public int getCount()
    {
        return Integer.MAX_VALUE;
    }

    @Override
    public Object getItem(int position) 
    {
        return objects[position % objects.length];
    }

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = super.getView(position % objects.length, convertView, parent);
		//int colorPos = position % colors.length;
		//view.setBackgroundColor(colors[colorPos]);
		return view;
	}
    
    
}
